<?php

namespace App\Models\hwtc;

use Illuminate\Database\Eloquent\Model;

class Apirole extends Model
{

    protected $table = 'api_roles';
    protected $guarded = [];

    public function apiusers ()
    {
        // 多对多的关系（一个角色赋予了多个用户）
        return $this->belongsToMany('App\Models\hwtc\Apiuser','api_role_user','api_role_id','api_user_id');

    }

    public function apipermissions()
    {
        //一个角色有多个权限
        return $this->belongsToMany('App\Models\hwtc\Apipermission','api_permission_role','api_role_id','api_permission_id');
    }

    static function getroles(){
        $roles=self::orderBy('id')->get();
        return $roles;
    }

}
